package com.xc.stock.constant;

/**
 * 
 * 错误提示
 * 
 * @author jnerh
 * @since 2023-07-17
 */
public enum ErrorTipEnum {
	NEED_REAL_NAME("tips.msg.005", "下单失败，请先实名认证"),
	USER_LOCK("tips.msg.006", "下单失败，账户已被锁定"),
	HOLIDAY("tips.msg.007", "周末或节假日不能交易！"),
	SITE_SETTING_NOT_EXISTS("tips.msg.008", "下单出错，网站设置表不存在"),
	NOT_BUY_TIME("tips.msg.009", "下单失败，不在交易时段内"),
	STOCK_CODE_ERROR("tips.msg.010", "下单失败，股票代码错误"),
	CANNOT_TRADE_STOCK("tips.msg.011", "下单失败，当前股票不能交易"),
	LESS_THAN_MIN_AMT("tips.msg.012", "下单失败，购买金额小于{buyMinAmt}元"),
	SAVE_POSITION_ERROR("tips.msg.013", "【用户交易下单】保存持仓记录出错"),
	ORDER_SUCCESS("tips.msg.014", "下单成功"),
	MODIFY_USER_AMT_ERROR("tips.msg.017", "【用户交易下单】修改用户金额出错"),
	UNKNOWN("UNKNOWN", "未知错误"),
	;

	String code;
	String remark;

	ErrorTipEnum(String code, String remark) {
		this.code = code;
		this.remark = remark;
	}
	
	public String code() {
		return code;
	}
	
	public String remark() {
		return remark;
	}
	
	public static String remark(String c) {
		ErrorTipEnum of = of(c);
		return of == null ? "" : of.remark;
	}
	
	public static ErrorTipEnum of(String c) {
		ErrorTipEnum[] enums = ErrorTipEnum.values();
		for (ErrorTipEnum e : enums) {
			if(e.code.equals(c)) {
				return e;
			}
		}

		return UNKNOWN;
	}
}
